package com.jjh.controller;

import com.jjh.consts.Result;
import com.jjh.service.OrderService;
import jakarta.annotation.Resource;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

@RestController
@RequestMapping("/api/order")
public class OrderController {

    @Resource
    private OrderService orderService;

    /**
     * 条件分页查询
     * @param page
     * @param size
     * @param map
     * @return
     */
    @PostMapping("/page/{page}/{size}")
    public Result page(@PathVariable("page")Integer page,
                       @PathVariable("size")Integer size,
                       @RequestBody Map<String,Object> map){

        return orderService.page(page,size,map);
    }

    /**
     * 根据订单号查询订单
     * @param orderId 订单号
     * @return 唯一的订单
     */
    @GetMapping("/{orderId}")
    public Result getByOrderId(@PathVariable("orderId")Long orderId){
        return orderService.getByOrderId(orderId);
    }





}
